package cc.rengu.igas.momp.core.service.trans;

import cc.rengu.igas.momp.common.constant.CommonConstant;
import cc.rengu.igas.momp.common.dao.*;
import cc.rengu.igas.momp.common.dao.impl.*;
import cc.rengu.igas.momp.common.entity.*;
import cc.rengu.igas.momp.common.enums.*;
import cc.rengu.igas.momp.common.model.bean.*;
import cc.rengu.igas.momp.common.util.CommonMessageCheck;
import cc.rengu.igas.momp.common.util.JsonOperation;
import cc.rengu.igas.momp.facade.bean.*;
import cc.rengu.igas.momp.facade.request.QueryCouponMcDetailInfoRequest;
import cc.rengu.igas.momp.facade.response.QueryCouponMcDetailInfoResponse;
import cc.rengu.oltp.service.base.RadpService;
import cc.rengu.oltp.service.common.constant.TreeNodeConstant;
import cc.rengu.oltp.service.common.enums.ChannelEnum;
import cc.rengu.oltp.service.common.enums.OltpRpcdEnum;
import cc.rengu.oltp.service.model.BizException;
import cc.rengu.oltp.service.model.BizResponse;
import cc.rengu.oltp.utility.bean.PageInfo;
import cc.rengu.oltp.utility.bean.PageResult;
import cc.rengu.oltp.utility.util.ConvertUtil;
import cc.rengu.oltp.utility.util.XmlTreeUtil;
import cc.rengu.utility.base.StringUtil;

import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 卡券类营销活动详细信息查询功能实现
 *
 * @author Jinan Liu
 * @date 2020/3/24 15:20
 */
public class QueryCouponMcDetailInfoService extends RadpService {

    private String globalInstId;
    private String globalQueryType;
    private String globalQueryRole;
    private String globalQueryId;
    private String globalQueryOrgId;
    private String globalMcNo;

    @Override
    protected int bizInit(String s) {
        return CommonConstant.PROCESS_SUCCESS;
    }

    @Override
    protected int bizProcess(String s, int i) {

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();

        try {

            QueryCouponMcDetailInfoRequest queryCouponMcDetailInfoRequest = new QueryCouponMcDetailInfoRequest();
            ConvertUtil.convertOutput(queryCouponMcDetailInfoRequest);

            QueryCouponMcDetailInfoResponse queryCouponMcDetailInfoResponse = new QueryCouponMcDetailInfoResponse();
            queryCouponMcDetailInfoResponse.setHeader(queryCouponMcDetailInfoRequest.getHeader());
            BizResponse<QueryCouponMcDetailInfoResponse> bizResponse = new BizResponse<>();
            bizResponse.setResult(queryCouponMcDetailInfoResponse);

            String timeStamp = new SimpleDateFormat(CommonConstant.TIMESTAMP_FORMAT).format(new Date());
            globalQueryType = queryCouponMcDetailInfoRequest.getQueryType();
            globalQueryId = queryCouponMcDetailInfoRequest.getQueryId();
            globalQueryOrgId = queryCouponMcDetailInfoRequest.getQueryOrgId();
            globalQueryRole = queryCouponMcDetailInfoRequest.getQueryRole();
            globalInstId = queryCouponMcDetailInfoRequest.getHeader().getInstId();
            globalMcNo = queryCouponMcDetailInfoRequest.getMcNo();
            rglog.info("机构<{}>在<{}>由<{}>开始查询卡券类营销活动详细信息流程", globalInstId, timeStamp, globalQueryId);

            /* 报文检查 */
            CommonMessageCheck.checkBizMessageHeader(globalQueryType, globalQueryId, globalQueryRole, rglog);

            /* 检查操作员所属机构号 */
            if (StringUtil.isNullorEmpty(globalQueryOrgId)) {
                rglog.error("法人机构号<{}>的操作员<{}>的所属机构为空!", globalInstId, globalQueryId);
                throw new BizException(RespCodeEnum.MSG_VALID_CHECK_ERROR.getRespCode(), RespCodeEnum.MSG_VALID_CHECK_ERROR.getRespDesc());
            }

            /* 检查营销活动编号 */
            if (StringUtil.isNullorEmpty(globalMcNo)) {
                rglog.error("法人机构号<{}>的操作员<{}>的营销活动编号为空!", globalInstId, globalQueryId);
                throw new BizException(RespCodeEnum.MSG_VALID_CHECK_ERROR.getRespCode(), RespCodeEnum.MSG_VALID_CHECK_ERROR.getRespDesc());
            }

            // 服务调用
            BizResponse<QueryCouponMcDetailInfoResponse> bizResponseNew = queryCouponMcDetailInfo(xmlTreeUtil, queryCouponMcDetailInfoRequest, queryCouponMcDetailInfoResponse);

            ConvertUtil.convertInput(bizResponseNew.getResult());

        } catch (BizException e) {
            try {
                xmlTreeUtil.setXmlTreeStringValue(TreeNodeConstant.RESP_CODE, e.getCode());
                xmlTreeUtil.setXmlTreeStringValue(TreeNodeConstant.RESP_DESC, e.getMessage());
            } catch (Exception e1) {
                rglog.error(StringUtil.ExceptionToString(e1));
            }
        } catch (Exception e) {
            rglog.error(StringUtil.ExceptionToString(e));
            try {
                xmlTreeUtil.setXmlTreeStringValue(TreeNodeConstant.RESP_CODE, OltpRpcdEnum.OLTP_PROCESS_ERROR.getRespCode());
                xmlTreeUtil.setXmlTreeStringValue(TreeNodeConstant.RESP_DESC, OltpRpcdEnum.OLTP_PROCESS_ERROR.getRespDesc());
            } catch (Exception e1) {
                rglog.error(StringUtil.ExceptionToString(e1));
            }
        }

        return CommonConstant.PROCESS_SUCCESS;
    }

    @Override
    protected int bizTerminate(String s) {
        return CommonConstant.PROCESS_SUCCESS;
    }

    /**
     * 查询卡券类营销活动详细信息
     *
     * @param xmlTreeUtil                     内部XML树
     * @param queryCouponMcDetailInfoRequest  卡券类活动详情查询接口请求报文
     * @param queryCouponMcDetailInfoResponse 卡券类活动详情查询接口应答报文
     * @return cc.rengu.oltp.service.model.BizResponse<cc.rengu.igas.momp.facade.response.QueryCouponMcDetailInfoResponse> 卡券类活动详情查询接口应答报文
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @since 2020/5/28 14:50
     */
    private BizResponse<QueryCouponMcDetailInfoResponse> queryCouponMcDetailInfo(XmlTreeUtil xmlTreeUtil, QueryCouponMcDetailInfoRequest queryCouponMcDetailInfoRequest, QueryCouponMcDetailInfoResponse queryCouponMcDetailInfoResponse) throws Exception {

        BizResponse<QueryCouponMcDetailInfoResponse> bizResponse = new BizResponse<>();


        /* 判断查询类型 */
        CpMcListInfoInObj cpMcListInfoInObj = new CpMcListInfoInObj();

        /* 机构编码 */
        cpMcListInfoInObj.setInstId(globalInstId);

        /* 营销活动编号 */
        cpMcListInfoInObj.setMcNo(globalMcNo);


        /* 先查询所有数据，在判断查询用户是否有权限获取到数据 */
        /* 根据角色权限查询数据 */
        switch (QueryTypeEnum.getByValue(globalQueryType)) {
            case BANK_QUERY_TYPE:
                /* 银行人员,需要拼接营销活动机构信息表查询 */

                /* 机构编号 */
                if (!StringUtil.isNullorEmpty(globalQueryOrgId)) {
                    cpMcListInfoInObj.setOrgId(globalQueryOrgId);
                }

                /* 银行人员查询营销活动详细信息 */
                queryCouponMcDetailInfoByBank(queryCouponMcDetailInfoResponse, cpMcListInfoInObj);

                break;

            case MCHNT_QYERY_TYPE:
                /* 商户人员,需要拼接营销活动商户信息表查询 */

                /* 根据商户编号查询商圈编号 */
                String mchntNo = globalQueryId;
                String mchntArea = null;
                TBMchntBaseInfo tbMchntBaseInfo = null;
                if (!StringUtil.isNullorEmpty(mchntNo)) {
                    /* 查询商户基本信息表 */
                    tbMchntBaseInfo = selectMompMchntBaseInfoByPrimaryKey(globalInstId, mchntNo);
                    if (null == tbMchntBaseInfo) {
                        rglog.error("查询法人机构<{}>商户<{}>基本信息失败!", globalInstId, mchntNo);
                        throw new BizException(RespCodeEnum.NO_TRANS_RECORD.getRespCode(), RespCodeEnum.NO_TRANS_RECORD.getRespDesc());
                    } else {
                        /* 商户编号 */
                        if (!StringUtil.isNullorEmpty(mchntNo)) {
                            cpMcListInfoInObj.setMchntNo(mchntNo);
                        }

                        /* 商圈编号 */
                        mchntArea = tbMchntBaseInfo.getMchntArea();
                        if (!StringUtil.isNullorEmpty(mchntArea)) {
                            cpMcListInfoInObj.setMchntArea(mchntArea);
                        }
                    }
                }

                /* 商户查询营销活动详细信息 */
                queryCouponMcDetailInfoByMchnt(queryCouponMcDetailInfoResponse, cpMcListInfoInObj);

                break;

            default:
                /* 其他查询角色不支持 */
                rglog.error("当前<{}>角色的查询用户<{}>无权限操作数据!", globalQueryRole, globalQueryType);
                throw new BizException(RespCodeEnum.NO_AUTHORIZATION_TO_OPER_ERROR.getRespCode(), RespCodeEnum.NO_AUTHORIZATION_TO_OPER_ERROR.getRespDesc());
        }

        bizResponse.setRspSysId(ChannelEnum.MOMP.getChannelType());
        bizResponse.setRespCode(RespCodeEnum.TRANS_SUCCESS.getRespCode());
        bizResponse.setRespDesc(RespCodeEnum.TRANS_SUCCESS.getRespDesc());

        queryCouponMcDetailInfoResponse.setRespCode(RespCodeEnum.TRANS_SUCCESS.getRespCode());
        queryCouponMcDetailInfoResponse.setRespDesc(RespCodeEnum.TRANS_SUCCESS.getRespDesc());
        bizResponse.setResult(queryCouponMcDetailInfoResponse);

        return bizResponse;
    }

    /**
     * 银行人员查询营销活动详细信息
     *
     * @param queryCouponMcDetailInfoResponse 卡券类活动详情查询接口应答报文
     * @param cpMcListInfoInObj               营销活动列表查询使用实体类入参
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 18:58     *
     */
    private void queryCouponMcDetailInfoByBank(QueryCouponMcDetailInfoResponse queryCouponMcDetailInfoResponse, CpMcListInfoInObj cpMcListInfoInObj) throws Exception {

        if (QueryRoleEnum.BANK_BASIC_QUERY_ROLE.getQueryRoleCode().equals(globalQueryRole) ||
                QueryRoleEnum.BANK_PUBLISH_QYERY_ROLE.getQueryRoleCode().equals(globalQueryRole)) {
            TMMcCouponInfo tmMcCouponInfo;

            if (QueryRoleEnum.BANK_BASIC_QUERY_ROLE.getQueryRoleCode().equals(globalQueryRole)) {

                /* 银行录入岗流程 */
                tmMcCouponInfo = selectCouponMcDetailInfoByBankBasicRole(cpMcListInfoInObj);
                if (null == tmMcCouponInfo) {
                    rglog.error("机构<{}>的卡券类营销活动<{}>的基本信息查询失败!用户无权限查看数据或不存在该营销活动", globalInstId, globalMcNo);
                    throw new BizException(RespCodeEnum.GET_MONEY_OFF_MC_DETAIL_ERROR.getRespCode(), RespCodeEnum.GET_MONEY_OFF_MC_DETAIL_ERROR.getRespDesc());
                }
            } else {

                /* 银行发布岗流程 */
                tmMcCouponInfo = selectCouponMcDetailInfoByBankPublishRole(cpMcListInfoInObj);
                if (null == tmMcCouponInfo) {
                    rglog.error("机构<{}>的卡券类营销活动<{}>的基本信息查询失败!用户无权限查看数据或不存在该营销活动", globalInstId, globalMcNo);
                    throw new BizException(RespCodeEnum.GET_MONEY_OFF_MC_DETAIL_ERROR.getRespCode(), RespCodeEnum.GET_MONEY_OFF_MC_DETAIL_ERROR.getRespDesc());
                }
            }

            /* 银行操作员和发布员都是从正式表查询数据,除了营销活动基本表外其他表查询语句相同 */

            /* 查询营销活动机构信息 */
            List<TMMcOrgInfo> mcOrgInfoList = getAllMcOrgListInfo();
            /** 卡券类活动详情接口去除商户信息 用户信息返回内容  银行审计岗 银行发布岗 */
            /* 查询营销活动商户信息 *//*
            List<Object> mcMchntInfoList = getAllMcMchntListInfo();

            */
            /* 查询营销活动用户信息 */
            List<TMMcUserInfo> mcUserInfoList = getAllMcUserListInfo();

            /* 查询营销活动时间信息 */
            List<TMMcTimeInfo> mcTimeInfoList = null;
            if (CommonConstant.SPECIFIC_TIME_SUPPORT.equals(tmMcCouponInfo.getMcTimeFlag())) {
                mcTimeInfoList = getAllMcTimeListInfo();
            }

            /* 查询营销活动规则信息 */
            List<TMMcCouponRuleInfo> mcCouponRuleInfoList = getAllMcRuleListInfo();
            /* 查询营销活动支付产品信息 */
            List<TMMcProductInfo> mcProductInfoList = getAllMcProductListInfo();
            /* 拼接交易信息 */
            CouponMcInfoBean couponMcInfoBean = convertMcInfo(tmMcCouponInfo);
            queryCouponMcDetailInfoResponse.setMcInfoObj(couponMcInfoBean);
            List<McOrgInfoBean> mcOrgInfoBeanList = mcOrgInfoList.stream().map(this::convertMcOrgInfo).collect(Collectors.toList());
            queryCouponMcDetailInfoResponse.setOrgInfoList(mcOrgInfoBeanList);
            /**卡券类活动详情接口去除商户信息 用户信息返回内容 */
            /*List<McMchntInfoBean> mcMchntInfoBeanList = new ArrayList<>();
            if(null != mcMchntInfoList && !mcMchntInfoList.isEmpty()){
                mcMchntInfoBeanList = mcMchntInfoList.stream().map(this::convertMcMchntInfo).collect(Collectors.toList());
            }
            queryCouponMcDetailInfoResponse.setMchntInfoList(mcMchntInfoBeanList);*/
            if (null != mcUserInfoList && !mcUserInfoList.isEmpty()) {
                List<McUserInfoBean> mcUserInfoBeanList = mcUserInfoList.stream().map(this::convertMcUserInfo).collect(Collectors.toList());
                queryCouponMcDetailInfoResponse.setUserInfoList(mcUserInfoBeanList);
            }
            if (CommonConstant.SPECIFIC_TIME_SUPPORT.equals(tmMcCouponInfo.getMcTimeFlag())) {
                List<McTimeInfoBean> mcTimeInfoBeanList = new ArrayList<>();
                if (null != mcTimeInfoList && !mcTimeInfoList.isEmpty()) {
                    mcTimeInfoBeanList = mcTimeInfoList.stream().map(this::convertMcTimeInfo).collect(Collectors.toList());
                }
                queryCouponMcDetailInfoResponse.setTimeInfoList(mcTimeInfoBeanList);
            }
            List<CouponRuleInfoBean> mcCouponRuleInfoBean = new ArrayList<>();
            if (null != mcCouponRuleInfoList && !mcCouponRuleInfoList.isEmpty()) {
                mcCouponRuleInfoBean = mcCouponRuleInfoList.stream().map(this::convertMcRuleInfo).collect(Collectors.toList());
            }
            queryCouponMcDetailInfoResponse.setRuleInfoList(mcCouponRuleInfoBean);
            List<McProductInfoBean> mcProductInfoBeanList = new ArrayList<>();
            if (null != mcProductInfoList && !mcProductInfoList.isEmpty()) {
                mcProductInfoBeanList = mcProductInfoList.stream().map(this::convertMcProductInfo).collect(Collectors.toList());
            }
            queryCouponMcDetailInfoResponse.setProductInfoList(mcProductInfoBeanList);

        } else if (QueryRoleEnum.BANK_AUDIT_QYERY_ROLE.getQueryRoleCode().equals(globalQueryRole)) {

            /* 银行审批岗流程 */
            TMPlatBizTmp tmPlatBizTmp = selectCouponMcDetailInfoByBankAuditRole(cpMcListInfoInObj);
            if (null == tmPlatBizTmp) {
                rglog.error("机构<{}>的卡券类营销活动<{}>的基本信息查询失败!用户无权限查看数据或不存在该营销活动", globalInstId, globalMcNo);
                throw new BizException(RespCodeEnum.GET_MONEY_OFF_MC_DETAIL_ERROR.getRespCode(), RespCodeEnum.GET_MONEY_OFF_MC_DETAIL_ERROR.getRespDesc());
            }

            /* 取临时表中所有数据 */
            MoMcListInfoInObj moMcListInfoInObj = new MoMcListInfoInObj();
            moMcListInfoInObj.setInstId(globalInstId);
            moMcListInfoInObj.setMcNo(globalMcNo);
            List<TMPlatBizTmp> tmPlatBizTmpList = getAllMcTmpInfo(moMcListInfoInObj);
            if (null == tmPlatBizTmpList || tmPlatBizTmpList.isEmpty()) {
                rglog.error("机构<{}>的卡券类营销活动<{}>的基本信息查询失败!用户无权限查看数据或不存在该营销活动", globalInstId, globalMcNo);
                throw new BizException(RespCodeEnum.GET_MONEY_OFF_MC_DETAIL_ERROR.getRespCode(), RespCodeEnum.GET_MONEY_OFF_MC_DETAIL_ERROR.getRespDesc());
            }

            /* 拆分数据 */

            /* 转换营销活动基本信息 */
            CouponMcInfoBean couponMcInfoBean = convertTmpMcInfo(tmPlatBizTmp);

            /* 转换营销活动机构信息 */
            List<TMPlatBizTmp> tmPlatBizTmpOrgList = tmPlatBizTmpList.stream().filter(record -> TableNameEnum.T_M_MC_ORG_INFO.getTableNameCode().equals(record.getOprTableEname())).collect(Collectors.toList());
            List<McOrgInfoBean> mcOrgInfoBeanList = tmPlatBizTmpOrgList.stream().map(this::convertTmpMcOrgInfo).collect(Collectors.toList());
            /**卡券类活动详情接口去除商户信息 用户信息返回内容  银行审批岗 */
            /* 查询营销活动商户信息 *//*
            List<TMPlatBizTmp> tmPlatBizTmpMchntList = tmPlatBizTmpList.stream().filter(record -> TableNameEnum.T_M_MC_MCHNT_INFO.getTableNameCode().equals(record.getOprTableEname())).collect(Collectors.toList());
            List<McMchntInfoBean> mcMchntInfoBeanList = tmPlatBizTmpMchntList.stream().map(this::convertTmpMcMchntInfo).collect(Collectors.toList());

            */
            /* 查询营销活动用户信息 */
            List<McUserInfoBean> mcUserInfoBeanList = new ArrayList<>();
            if (CommonConstant.SPECIFIC_CLIENT_SUPPORT.equals(couponMcInfoBean.getClientRange())) {
                List<TMPlatBizTmp> tmPlatBizTmpUserList = tmPlatBizTmpList.stream().filter(record -> TableNameEnum.T_M_MC_USER_INFO.getTableNameCode().equals(record.getOprTableEname())).collect(Collectors.toList());
                mcUserInfoBeanList = tmPlatBizTmpUserList.stream().map(this::convertTmpMcUserInfo).collect(Collectors.toList());
            }

            /* 查询营销活动时间信息 */
            List<McTimeInfoBean> mcTimeInfoBeanList = new ArrayList<>();
            if (CommonConstant.SPECIFIC_TIME_SUPPORT.equals(couponMcInfoBean.getMcTimeFlag())) {
                List<TMPlatBizTmp> tmPlatBizTmpTimeList = tmPlatBizTmpList.stream().filter(record -> TableNameEnum.T_M_MC_TIME_INFO.getTableNameCode().equals(record.getOprTableEname())).collect(Collectors.toList());
                mcTimeInfoBeanList = tmPlatBizTmpTimeList.stream().map(this::convertTmpMcTimeInfo).collect(Collectors.toList());

            }

            /* 查询营销活动规则信息 */
            List<TMPlatBizTmp> tmPlatBizTmpRuleList = tmPlatBizTmpList.stream().filter(record -> TableNameEnum.T_M_MC_CP_RULE_INFO.getTableNameCode().equals(record.getOprTableEname())).collect(Collectors.toList());
            List<CouponRuleInfoBean> couponRuleInfoBeanList = tmPlatBizTmpRuleList.stream().map(this::convertTmpMcRuleInfo).collect(Collectors.toList());

            /* 查询营销活动支付产品信息 */
            List<TMPlatBizTmp> tmPlatBizTmpProdList = tmPlatBizTmpList.stream().filter(record -> TableNameEnum.T_M_MC_PROD_INFO.getTableNameCode().equals(record.getOprTableEname())).collect(Collectors.toList());
            List<McProductInfoBean> mcProductInfoBeanList = tmPlatBizTmpProdList.stream().map(this::convertTmpMcProductInfo).collect(Collectors.toList());

            /* 拼接交易信息 */
            queryCouponMcDetailInfoResponse.setMcInfoObj(couponMcInfoBean);
            queryCouponMcDetailInfoResponse.setOrgInfoList(mcOrgInfoBeanList);
            /** 卡券类活动详情接口去除商户信息 用户信息返回内容 */
            /*queryCouponMcDetailInfoResponse.setMchntInfoList(mcMchntInfoBeanList);*/
            if (CommonConstant.SPECIFIC_CLIENT_SUPPORT.equals(couponMcInfoBean.getClientRange())) {
                queryCouponMcDetailInfoResponse.setUserInfoList(mcUserInfoBeanList);
            }
            if (CommonConstant.SPECIFIC_TIME_SUPPORT.equals(couponMcInfoBean.getMcTimeFlag())) {
                queryCouponMcDetailInfoResponse.setTimeInfoList(mcTimeInfoBeanList);
            }
            queryCouponMcDetailInfoResponse.setRuleInfoList(couponRuleInfoBeanList);
            queryCouponMcDetailInfoResponse.setProductInfoList(mcProductInfoBeanList);

        } else {
            /* 其他查询角色不支持 */
            rglog.error("当前<{}>角色的查询用户<{}>无权限操作数据!", globalQueryRole, globalQueryType);
            throw new BizException(RespCodeEnum.NO_AUTHORIZATION_TO_OPER_ERROR.getRespCode(), RespCodeEnum.NO_AUTHORIZATION_TO_OPER_ERROR.getRespDesc());
        }

    }

    /**
     * 商户查询营销活动详细信息
     *
     * @param queryCouponMcDetailInfoResponse 卡券类活动详情查询接口应答报文
     * @param cpMcListInfoInObj               营销活动列表查询使用实体类入参
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:23
     */
    private void queryCouponMcDetailInfoByMchnt(QueryCouponMcDetailInfoResponse queryCouponMcDetailInfoResponse, CpMcListInfoInObj cpMcListInfoInObj) throws Exception {

        /* 查询营销活动基本信息 */
        TMMcCouponInfo tmMcCouponInfo;
        if (StringUtil.isNullorEmpty(cpMcListInfoInObj.getMchntArea())) {
            tmMcCouponInfo = selectCouponMcDetailInfoByMchnt(cpMcListInfoInObj);
        } else {
            tmMcCouponInfo = selectCouponMcDetailInfoByMchntWithArea(cpMcListInfoInObj);
        }
        if (null == tmMcCouponInfo) {
            rglog.error("机构<{}>的卡券类营销活动<{}>的基本信息查询失败!商户无权限查看数据或不存在该营销活动", globalInstId, globalMcNo);
            throw new BizException(RespCodeEnum.GET_MONEY_OFF_MC_DETAIL_ERROR.getRespCode(), RespCodeEnum.GET_MONEY_OFF_MC_DETAIL_ERROR.getRespDesc());
        }

        /* 查询营销活动机构信息 */
        List<TMMcOrgInfo> mcOrgInfoList = getAllMcOrgListInfo();
        if (null == mcOrgInfoList || mcOrgInfoList.isEmpty()) {
            rglog.error("机构<{}>的卡券类营销活动<{}>的机构信息查询失败!", globalInstId, globalMcNo);
            throw new BizException(RespCodeEnum.GET_MC_ORG_INFO_ERROR.getRespCode(), RespCodeEnum.GET_MC_ORG_INFO_ERROR.getRespDesc());
        }

        /** 卡券类活动详情接口去除商户信息 用户信息返回内容 *、
         /* 查询营销活动商户信息 */
        /*
        List<Object> mcMchntInfoList = getAllMcMchntListInfo();
        if (null == mcMchntInfoList || mcMchntInfoList.isEmpty()) {
            rglog.error("机构<{}>的卡券类营销活动<{}>的商户信息查询失败!", globalInstId, globalMcNo);
            throw new BizException(RespCodeEnum.GET_MC_MCHNT_INFO_ERROR.getRespCode(), RespCodeEnum.GET_MC_MCHNT_INFO_ERROR.getRespDesc());
        }*/

        /* 查询营销活动用户信息 */
        List<TMMcUserInfo> mcUserInfoList = getAllMcUserListInfo();

        /* 查询营销活动时间信息 */
        List<TMMcTimeInfo> mcTimeInfoList = null;
        if (CommonConstant.SPECIFIC_TIME_SUPPORT.equals(tmMcCouponInfo.getMcTimeFlag())) {
            mcTimeInfoList = getAllMcTimeListInfo();
            if (null == mcTimeInfoList || mcTimeInfoList.isEmpty()) {
                rglog.error("机构<{}>的卡券类营销活动<{}>的时间信息查询失败!", globalInstId, globalMcNo);
                throw new BizException(RespCodeEnum.GET_MC_TIME_INFO_ERROR.getRespCode(), RespCodeEnum.GET_MC_TIME_INFO_ERROR.getRespDesc());
            }
        }

        /* 查询营销活动规则信息 */
        List<TMMcCouponRuleInfo> mcCouponRuleInfoList = getAllMcRuleListInfo();
        if (null == mcCouponRuleInfoList || mcCouponRuleInfoList.isEmpty()) {
            rglog.error("机构<{}>的卡券类营销活动<{}>的卡券类规则查询失败!", globalInstId, globalMcNo);
            throw new BizException(RespCodeEnum.GET_MC_RULE_INFO_ERROR.getRespCode(), RespCodeEnum.GET_MC_RULE_INFO_ERROR.getRespDesc());
        }

        /* 查询营销活动支付产品信息 */
        List<TMMcProductInfo> mcProductInfoList = getAllMcProductListInfo();

        /* 拼接交易信息 */
        CouponMcInfoBean couponMcInfoBean = convertMcInfo(tmMcCouponInfo);
        queryCouponMcDetailInfoResponse.setMcInfoObj(couponMcInfoBean);
        List<McOrgInfoBean> mcOrgInfoBeanList = mcOrgInfoList.stream().map(this::convertMcOrgInfo).collect(Collectors.toList());
        queryCouponMcDetailInfoResponse.setOrgInfoList(mcOrgInfoBeanList);
        /** 卡券类活动详情接口去除商户信息 用户信息返回内容 */
        /*List<McMchntInfoBean> mcMchntInfoBeanList = mcMchntInfoList.stream().map(this::convertMcMchntInfo).collect(Collectors.toList());
        queryCouponMcDetailInfoResponse.setMchntInfoList(mcMchntInfoBeanList);*/
        if (null != mcUserInfoList && !mcUserInfoList.isEmpty()) {
            List<McUserInfoBean> mcUserInfoBeanList = mcUserInfoList.stream().map(this::convertMcUserInfo).collect(Collectors.toList());
            queryCouponMcDetailInfoResponse.setUserInfoList(mcUserInfoBeanList);
        }
        if (CommonConstant.SPECIFIC_TIME_SUPPORT.equals(tmMcCouponInfo.getMcTimeFlag())) {
            if (mcTimeInfoList != null) {
                List<McTimeInfoBean> mcTimeInfoBeanList = mcTimeInfoList.stream().map(this::convertMcTimeInfo).collect(Collectors.toList());
                queryCouponMcDetailInfoResponse.setTimeInfoList(mcTimeInfoBeanList);
            }
        }
        List<CouponRuleInfoBean> mcCouponRuleInfoBean = mcCouponRuleInfoList.stream().map(this::convertMcRuleInfo).collect(Collectors.toList());
        queryCouponMcDetailInfoResponse.setRuleInfoList(mcCouponRuleInfoBean);
        List<McProductInfoBean> mcProductInfoBeanList = new ArrayList<>();
        if (null != mcProductInfoList && !mcProductInfoList.isEmpty()) {
            mcProductInfoBeanList = mcProductInfoList.stream().map(this::convertMcProductInfo).collect(Collectors.toList());
        }
        queryCouponMcDetailInfoResponse.setProductInfoList(mcProductInfoBeanList);
    }

    /**
     * 银行操作员查询营销活动基本信息表数据(正式表)
     *
     * @param cpMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMMcCouponInfo 卡券类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:11
     */
    private TMMcCouponInfo selectCouponMcDetailInfoByBankBasicRole(CpMcListInfoInObj cpMcListInfoInObj) throws Exception {
        McDetailInfoMapper mcDetailInfoMapper = new McDetailInfoMapperImpl();
        return mcDetailInfoMapper.selectCouponMcDetailInfoByBankBasicRole(cpMcListInfoInObj);
    }

    /**
     * 银行审批员查询营销活动基本信息表数据
     *
     * @param cpMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMPlatBizTmp 业务数据临时表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:11
     */
    private TMPlatBizTmp selectCouponMcDetailInfoByBankAuditRole(CpMcListInfoInObj cpMcListInfoInObj) throws Exception {
        PlatBizTmpMapper platBizTmpMapper = new PlatBizTmpMapperImpl();
        return platBizTmpMapper.selectCouponMcDetailInfoByBankAuditRole(cpMcListInfoInObj);
    }

    /**
     * 银行发布员查询营销活动基本信息表数据
     *
     * @param cpMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMMcCouponInfo 卡券类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:11
     */
    private TMMcCouponInfo selectCouponMcDetailInfoByBankPublishRole(CpMcListInfoInObj cpMcListInfoInObj) throws Exception {
        McDetailInfoMapper mcDetailInfoMapper = new McDetailInfoMapperImpl();
        return mcDetailInfoMapper.selectCouponMcDetailInfoByBankPublishRole(cpMcListInfoInObj);
    }

    /**
     * 商户查询营销活动基本信息表数据
     *
     * @param cpMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMMcCouponInfo 卡券类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:10
     */
    private TMMcCouponInfo selectCouponMcDetailInfoByMchnt(CpMcListInfoInObj cpMcListInfoInObj) throws Exception {
        McDetailInfoMapper mcDetailInfoMapper = new McDetailInfoMapperImpl();
        return mcDetailInfoMapper.selectCouponMcDetailInfoByMchnt(cpMcListInfoInObj);
    }

    /**
     * 商户查询营销活动基本信息表数据
     *
     * @param cpMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return cc.rengu.igas.momp.common.entity.TMMcCouponInfo 卡券类营销活动信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:10
     */
    private TMMcCouponInfo selectCouponMcDetailInfoByMchntWithArea(CpMcListInfoInObj cpMcListInfoInObj) throws Exception {
        McDetailInfoMapper mcDetailInfoMapper = new McDetailInfoMapperImpl();
        return mcDetailInfoMapper.selectCouponMcDetailInfoByMchntWithArea(cpMcListInfoInObj);
    }

    /**
     * 获取营销活动机构信息列表(正式表)
     *
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMMcOrgInfo> 营销活动机构信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 18:36
     */
    private List<TMMcOrgInfo> getAllMcOrgListInfo() throws Exception {

        McOrgInfoMapper mcOrgInfoMapper = new McOrgInfoMapperImpl();
        return mcOrgInfoMapper.selectMcOrgInfoList(globalInstId, globalMcNo);
    }

    /**
     * 获取营销活动商户信息列表(正式表)
     *
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMMcMchntInfo> 营销活动商户信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 18:35
     */
    private List<Object> getAllMcMchntListInfo() throws Exception {

        List<Object> tmMcMchntInfoList = new ArrayList<>();
        PageInfo pageInfo = new PageInfo();
        int i = 0;
        pageInfo.setPageIndex(i);
        pageInfo.setPageSize(9999);
        TMMcMchntInfo tmMcMchntInfo = new TMMcMchntInfo();
        tmMcMchntInfo.setInstId(globalInstId);
        tmMcMchntInfo.setMcNo(globalMcNo);
        McMchntInfoMapper mcMchntInfoMapper = new McMchntInfoMapperImpl();
        PageResult tmMcMchntInfoPageInfo = mcMchntInfoMapper.selectMcMchntInfoList(tmMcMchntInfo, pageInfo);
        if (null != tmMcMchntInfoPageInfo && null != tmMcMchntInfoPageInfo.getResult()) {
            tmMcMchntInfoList.addAll(tmMcMchntInfoPageInfo.getResult());
        }
        while (null != tmMcMchntInfoPageInfo && null != tmMcMchntInfoPageInfo.getResult() && tmMcMchntInfoPageInfo.getResult().size() >= 1) {
            i++;
            pageInfo.setPageIndex(i);
            tmMcMchntInfoPageInfo = mcMchntInfoMapper.selectMcMchntInfoList(tmMcMchntInfo, pageInfo);
            if (null != tmMcMchntInfoPageInfo && null != tmMcMchntInfoPageInfo.getResult()) {
                tmMcMchntInfoList.addAll(tmMcMchntInfoPageInfo.getResult());
            }
        }
        return tmMcMchntInfoList;
    }

    /**
     * 获取营销活动用户信息列表(正式表)
     *
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMMcUserInfo> 营销活动用户信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 18:38
     */
    private List<TMMcUserInfo> getAllMcUserListInfo() throws Exception {

        McUserInfoMapper mcUserInfoMapper = new McUserInfoMapperImpl();
        return mcUserInfoMapper.selectMcUserInfoList(globalInstId, globalMcNo);
    }

    /**
     * 获取营销活动时间信息列表(正式表)
     *
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMMcTimeInfo> 营销活动时间信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 18:38
     */
    private List<TMMcTimeInfo> getAllMcTimeListInfo() throws Exception {

        McTimeInfoMapper mcTimeInfoMapper = new McTimeInfoMapperImpl();
        return mcTimeInfoMapper.selectMcTimeInfoList(globalInstId, globalMcNo);
    }

    /**
     * 获取营销活动规则信息列表(正式表)
     *
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMMcCouponRuleInfo> 卡券类营销活动规则表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 18:40
     */
    private List<TMMcCouponRuleInfo> getAllMcRuleListInfo() throws Exception {

        McRuleInfoMapper mcRuleInfoMapper = new McRuleInfoMapperImpl();
        return mcRuleInfoMapper.selectCouponRuleInfoList(globalInstId, globalMcNo);
    }

    /**
     * 获取营销活动支付产品信息列表(正式表)
     *
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMMcProductInfo> 营销活动产品信息表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 18:41
     */
    private List<TMMcProductInfo> getAllMcProductListInfo() throws Exception {

        McProductInfoMapper mcProductInfoMapper = new McProductInfoMapperImpl();
        return mcProductInfoMapper.selectMcProductInfoList(globalInstId, globalMcNo);
    }

    /**
     * 银行审批岗获取指定营销活动所有待审批数据
     *
     * @param moMcListInfoInObj 营销活动列表查询使用实体类入参
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMPlatBizTmp> 业务数据临时表
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 19:55
     */
    private List<TMPlatBizTmp> getAllMcTmpInfo(MoMcListInfoInObj moMcListInfoInObj) throws Exception {
        List<Object> tmMcMchntInfoList = new ArrayList<>();
        PageInfo pageInfo = new PageInfo();
        int i = 0;
        pageInfo.setPageIndex(i);
        pageInfo.setPageSize(9999);
        PlatBizTmpMapper platBizTmpMapper = new PlatBizTmpMapperImpl();
        PageResult tmMcMchntInfoPageInfo = platBizTmpMapper.selectSingleMcAllDetailInfoByBankAuditRole(moMcListInfoInObj, pageInfo);
        if (null != tmMcMchntInfoPageInfo && null != tmMcMchntInfoPageInfo.getResult()) {
            tmMcMchntInfoList.addAll(tmMcMchntInfoPageInfo.getResult());
        }
        while (null != tmMcMchntInfoPageInfo && null != tmMcMchntInfoPageInfo.getResult() && tmMcMchntInfoPageInfo.getResult().size() >= 1) {
            i++;
            pageInfo.setPageIndex(i);
            tmMcMchntInfoPageInfo = platBizTmpMapper.selectSingleMcAllDetailInfoByBankAuditRole(moMcListInfoInObj, pageInfo);
            if (null != tmMcMchntInfoPageInfo && null != tmMcMchntInfoPageInfo.getResult()) {
                tmMcMchntInfoList.addAll(tmMcMchntInfoPageInfo.getResult());
            }
        }
        List<TMPlatBizTmp> tmpMcMchntInfoList = tmMcMchntInfoList.stream().map(item -> (TMPlatBizTmp) (item)).collect(Collectors.toList());
        return tmpMcMchntInfoList;
    }

    /**
     * 营销活动信息数据库实体类和接口实体类数据转换
     *
     * @param mcCouponInfo 卡券类营销活动信息表
     * @return cc.rengu.igas.momp.facade.bean.CouponMcInfoBean 卡券类活动基本信息对象
     * @author Jinan Liu
     * @date 2020/4/1 10:27
     */
    private CouponMcInfoBean convertMcInfo(TMMcCouponInfo mcCouponInfo) {
        CouponMcInfoBean couponMcInfoBean = new CouponMcInfoBean();
        try {
            /* 法人机构号 */
            couponMcInfoBean.setInstId(mcCouponInfo.getInstId());
            /* 营销活动编号 */
            couponMcInfoBean.setMcNo(mcCouponInfo.getMcNo());
            /* 营销活动名称 */
            couponMcInfoBean.setMcName(mcCouponInfo.getMcName());
            /* 营销活动类型 */
            couponMcInfoBean.setMcType(mcCouponInfo.getMcType());
            /* 营销活动状态 */
            couponMcInfoBean.setMcStatus(mcCouponInfo.getMcStatus());
            /* 活动起始日期 */
            couponMcInfoBean.setMcStartDate(mcCouponInfo.getMcStartDate());
            /* 活动截止日期 */
            couponMcInfoBean.setMcEndDate(mcCouponInfo.getMcEndDate());
            /* 活动结束日期 */
            couponMcInfoBean.setMcActualEndDate(mcCouponInfo.getMcActualEndDate());
            /* 活动时间标志 */
            couponMcInfoBean.setMcTimeFlag(mcCouponInfo.getMcTimeFlag());
            /* 出资方 */
            couponMcInfoBean.setSponsor(mcCouponInfo.getSponsor());
            /* 参与次数限制 */
            couponMcInfoBean.setRestriction(mcCouponInfo.getRestriction());
            /* 客户范围 */
            couponMcInfoBean.setClientRange(mcCouponInfo.getClientRange());
            /* 商户范围 */
            couponMcInfoBean.setMerchantRange(mcCouponInfo.getMerchantRange());
            /* 新增商户活动标志 */
            couponMcInfoBean.setNewMchntFlag(mcCouponInfo.getNewMchntFlag());
            /* 限制金额下限 */
            couponMcInfoBean.setAmtLimitFloor(mcCouponInfo.getAmtLimitFloor());
            /* 限制金额上限 */
            couponMcInfoBean.setAmtLimitCelling(mcCouponInfo.getAmtLimitCelling());
            /* 预算充值方式 */
            couponMcInfoBean.setBudgetRechargeMethod(mcCouponInfo.getBudgetRechargeMethod());
            /* 预算 */
            couponMcInfoBean.setBudget(mcCouponInfo.getBudget());
            /* 银行出资预算 */
            couponMcInfoBean.setBankBudget(mcCouponInfo.getBankBudget());
            /* 预期参与商户数量 */
            couponMcInfoBean.setExpectMchntQty(mcCouponInfo.getExpectMchntQty());
            /* 银行出资比例 */
            couponMcInfoBean.setBankBudgetRatio(mcCouponInfo.getBankBudgetRatio());
            /* 购买标志 */
            couponMcInfoBean.setPurchaseFlag(mcCouponInfo.getPurchaseFlag());
            /* 卡券生效时间 */
            couponMcInfoBean.setAvailableDate(mcCouponInfo.getAvailableDate());
            /* 卡券有效期标志 */
            couponMcInfoBean.setCouponDateFlag(mcCouponInfo.getCouponDateFlag());
            /* 卡券有效起始日期 */
            couponMcInfoBean.setCouponStartDate(mcCouponInfo.getCouponStartDate());
            /* 卡券有效结束日期 */
            couponMcInfoBean.setCouponEndDate(mcCouponInfo.getCouponEndDate());
            /* 卡券相对周期 */
            couponMcInfoBean.setCouponPeriod(mcCouponInfo.getCouponPeriod());
            /* 卡券库存 */
            couponMcInfoBean.setCouponInventory(mcCouponInfo.getCouponInventory());
            /* 卡券未领取张数 */
            couponMcInfoBean.setCouponRest(mcCouponInfo.getCouponRest());
            /* 卡券已领取张数 */
            couponMcInfoBean.setCouponClaimed(mcCouponInfo.getCouponClaimed());
            /* 卡券已核销张数 */
            couponMcInfoBean.setCouponRedeemed(mcCouponInfo.getCouponRedeemed());
            /* 审批状态   */
            couponMcInfoBean.setAuditStatus(mcCouponInfo.getAuditStatus());
            /* 创建人 */
            couponMcInfoBean.setOprId(mcCouponInfo.getOprId());
            /* 创建时间 */
            couponMcInfoBean.setCreateTime(mcCouponInfo.getCreateTime());
            /* 最后修改人 */
            couponMcInfoBean.setLastOprId(mcCouponInfo.getLastOprId());
            /* 修改时间 */
            couponMcInfoBean.setUpdateTime(mcCouponInfo.getUpdateTime());
            /* 审批拒绝原因 */
            couponMcInfoBean.setAuditRefuseReason(mcCouponInfo.getAuditRefuseReason());
            /* 发布拒绝原因 */
            couponMcInfoBean.setPublishRefuseReason(mcCouponInfo.getPublishRefuseReason());
            /* 备用字段1 */
            couponMcInfoBean.setRemark1(mcCouponInfo.getRemark1());
            /* 备用字段2 */
            couponMcInfoBean.setRemark2(mcCouponInfo.getRemark2());
            /* 备用字段3 */
            couponMcInfoBean.setRemark2(mcCouponInfo.getRemark3());
            /* 备用字段4 */
            couponMcInfoBean.setRemark2(mcCouponInfo.getRemark4());
            /* 备用字段5 */
            couponMcInfoBean.setRemark2(mcCouponInfo.getRemark5());
            /* 指定卡券领取渠道 */
            couponMcInfoBean.setClaimChannelId(mcCouponInfo.getClaimChannelId());
            /* 强制终止原因*/
            couponMcInfoBean.setNfrcTmnlRsn(mcCouponInfo.getNfrcTmnlRsn());

        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("转换营销活动信息异常,异常信息:<{}>", byteArrayOutputStream.toString());
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return couponMcInfoBean;
    }

    /**
     * 卡券类营销活动基本信息数据库临时表实体类和接口实体类数据转换
     *
     * @param tmPlatBizTmp 业务数据临时表
     * @return cc.rengu.igas.momp.facade.bean.CouponMcInfoBean 卡券类活动基本信息对象
     * @author Jinan Liu
     * @date 2020/5/28 20:35
     */
    private CouponMcInfoBean convertTmpMcInfo(TMPlatBizTmp tmPlatBizTmp) {
        CouponMcInfoBean couponMcInfoBean = new CouponMcInfoBean();
        try {

            JsonTmpCpMcInfo jsonTmpCpMcInfo = JsonOperation.parseCpMcInfoTmpBizData1(tmPlatBizTmp, rglog);

            /* 营销活动编号 */
            couponMcInfoBean.setMcNo(jsonTmpCpMcInfo.getMcNo());
            /* 营销活动名称 */
            couponMcInfoBean.setMcName(jsonTmpCpMcInfo.getMcName());
            /* 营销活动类型 */
            couponMcInfoBean.setMcType(jsonTmpCpMcInfo.getMcType());
            /* 营销活动状态 */
            couponMcInfoBean.setMcStatus(jsonTmpCpMcInfo.getMcStatus());
            /* 活动起始日期 */
            couponMcInfoBean.setMcStartDate(jsonTmpCpMcInfo.getMcStartDate());
            /* 活动截止日期 */
            couponMcInfoBean.setMcEndDate(jsonTmpCpMcInfo.getMcEndDate());
            /* 活动结束日期 */
            couponMcInfoBean.setMcActualEndDate(jsonTmpCpMcInfo.getMcActualEndDate());
            /* 活动时间标志 */
            couponMcInfoBean.setMcTimeFlag(jsonTmpCpMcInfo.getMcTimeFlag());
            /* 出资方 */
            couponMcInfoBean.setSponsor(jsonTmpCpMcInfo.getSponsor());
            /* 参与次数限制 */
            couponMcInfoBean.setRestriction(jsonTmpCpMcInfo.getRestriction());
            /* 客户范围 */
            couponMcInfoBean.setClientRange(jsonTmpCpMcInfo.getClientRange());
            /* 商户范围 */
            couponMcInfoBean.setMerchantRange(jsonTmpCpMcInfo.getMerchantRange());
            /* 新增商户活动标志 */
            couponMcInfoBean.setNewMchntFlag(jsonTmpCpMcInfo.getNewMchntFlag());
            /* 限制金额下限 */
            couponMcInfoBean.setAmtLimitFloor(jsonTmpCpMcInfo.getAmtLimitFloor());
            /* 限制金额上限 */
            couponMcInfoBean.setAmtLimitCelling(jsonTmpCpMcInfo.getAmtLimitCelling());
            /* 预算充值方式 */
            couponMcInfoBean.setBudgetRechargeMethod(jsonTmpCpMcInfo.getBudgetRechargeMethod());
            /* 预算 */
            couponMcInfoBean.setBudget(jsonTmpCpMcInfo.getBudget());
            /* 银行出资预算 */
            couponMcInfoBean.setBankBudget(jsonTmpCpMcInfo.getBankBudget());
            /* 预期参与商户数量 */
            couponMcInfoBean.setExpectMchntQty(jsonTmpCpMcInfo.getExpectMchntQty());
            /* 银行出资比例 */
            couponMcInfoBean.setBankBudgetRatio(jsonTmpCpMcInfo.getBankBudgetRatio());
            /* 购买标志 */
            couponMcInfoBean.setPurchaseFlag(jsonTmpCpMcInfo.getPurchaseFlag());
            /* 卡券生效时间 */
            couponMcInfoBean.setAvailableDate(jsonTmpCpMcInfo.getAvailableDate());
            /* 卡券有效期标志 */
            couponMcInfoBean.setCouponDateFlag(jsonTmpCpMcInfo.getCouponDateFlag());
            /* 卡券有效起始日期 */
            couponMcInfoBean.setCouponStartDate(jsonTmpCpMcInfo.getCouponStartDate());
            /* 卡券有效结束日期 */
            couponMcInfoBean.setCouponEndDate(jsonTmpCpMcInfo.getCouponEndDate());
            /* 卡券相对周期 */
            couponMcInfoBean.setCouponPeriod(jsonTmpCpMcInfo.getCouponPeriod());
            /* 卡券库存 */
            couponMcInfoBean.setCouponInventory(jsonTmpCpMcInfo.getCouponInventory());
            /* 卡券库存 */
            couponMcInfoBean.setCouponRest(jsonTmpCpMcInfo.getCouponRest());
            /* 卡券已领取张数 */
            couponMcInfoBean.setCouponClaimed(jsonTmpCpMcInfo.getCouponClaimed());
            /* 卡券已核销张数 */
            couponMcInfoBean.setCouponRedeemed(jsonTmpCpMcInfo.getCouponRedeemed());
            /* 审批状态   */
            couponMcInfoBean.setAuditStatus(tmPlatBizTmp.getAuditStatus());
            /* 创建人 */
            couponMcInfoBean.setOprId(tmPlatBizTmp.getOprId());
            /* 创建时间 */
            couponMcInfoBean.setCreateTime(tmPlatBizTmp.getCreateTime());
            /* 最后修改人 */
            couponMcInfoBean.setLastOprId(tmPlatBizTmp.getLastOprId());
            /* 修改时间 */
            couponMcInfoBean.setUpdateTime(tmPlatBizTmp.getLastUpdateTime());
            /* 审批拒绝原因 */
            couponMcInfoBean.setAuditRefuseReason(tmPlatBizTmp.getAuditRefuseReason());
            /* 备用字段1 */
            couponMcInfoBean.setRemark1(tmPlatBizTmp.getRemark1());
            /* 备用字段2 */
            couponMcInfoBean.setRemark2(tmPlatBizTmp.getRemark2());
            /* 备用字段3 */
            couponMcInfoBean.setRemark2(tmPlatBizTmp.getRemark3());
            /* 备用字段4 */
            couponMcInfoBean.setRemark2(tmPlatBizTmp.getRemark4());
            /* 备用字段5 */
            couponMcInfoBean.setRemark2(tmPlatBizTmp.getRemark5());
            /* 指定卡券领取渠道 */
            couponMcInfoBean.setClaimChannelId(jsonTmpCpMcInfo.getClaimChannelId());

        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("转换营销活动信息异常,异常信息:<{}>", byteArrayOutputStream.toString());
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return couponMcInfoBean;
    }

    /**
     * 营销活动机构信息数据库实体类和接口实体类数据转换
     *
     * @param mcOrgInfo 营销活动机构信息表
     * @return cc.rengu.igas.momp.facade.bean.McOrgInfoBean 营销活动机构信息对象
     * @author Jinan Liu
     * @date 2020/4/1 10:33
     */
    private McOrgInfoBean convertMcOrgInfo(TMMcOrgInfo mcOrgInfo) {
        McOrgInfoBean mcOrgInfoBean = new McOrgInfoBean();
        try {
            /* 机构编号 */
            mcOrgInfoBean.setOrgId(mcOrgInfo.getOrgId());
            /* 机构层级 */
            mcOrgInfoBean.setOrgHierarchy(mcOrgInfo.getOrgHierarchy());
            /* 机构名称 */
            mcOrgInfoBean.setOrgName(mcOrgInfo.getOrgName());

        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("转换营销活动机构信息异常,异常信息:<{}>", byteArrayOutputStream.toString());
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return mcOrgInfoBean;
    }

    /**
     * 营销活动机构信息数据库临时表实体类和接口实体类数据转换
     *
     * @param tmPlatBizTmp 业务数据临时表
     * @return cc.rengu.igas.momp.facade.bean.McOrgInfoBean 营销活动机构信息对象
     * @author Jinan Liu
     * @date 2020/5/28 20:01
     */
    private McOrgInfoBean convertTmpMcOrgInfo(TMPlatBizTmp tmPlatBizTmp) {

        McOrgInfoBean mcOrgInfoBean = new McOrgInfoBean();
        try {

            JsonTmpMcOrgInfo jsonTmpMcOrgInfo = JsonOperation.parseTmpMcOrgInfoBizData1(tmPlatBizTmp, rglog);

            /* 机构编号 */
            mcOrgInfoBean.setOrgId(jsonTmpMcOrgInfo.getOrgId());
            /* 机构层级 */
            mcOrgInfoBean.setOrgHierarchy(jsonTmpMcOrgInfo.getOrgHierarchy());
            /* 机构名称 */
            mcOrgInfoBean.setOrgName(jsonTmpMcOrgInfo.getOrgName());

        } catch (Exception e) {
            rglog.error("转换临时表营销活动机构信息异常,异常信息:<{}>", StringUtil.ExceptionToString(e));
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return mcOrgInfoBean;
    }

    /**
     * 营销活动商户信息数据库实体类和接口实体类数据转换
     *
     * @param object 营销活动商户信息表
     * @return cc.rengu.igas.momp.facade.bean.McMchntInfoBean 营销活动商户信息对象
     * @author Jinan Liu
     * @date 2020/4/1 10:33
     */
    private McMchntInfoBean convertMcMchntInfo(Object object) {
        McMchntInfoBean mcMchntInfoBean = new McMchntInfoBean();
        TMMcMchntInfo mcMchntInfo = (TMMcMchntInfo) object;
        try {
            /* 商户范围类型 */
            mcMchntInfoBean.setMchntType(mcMchntInfo.getMchntType());
            /* 商户范围号 */
            mcMchntInfoBean.setMchntNo(mcMchntInfo.getMchntNo());
            /* 商户范围名称 */
            mcMchntInfoBean.setMchntName(mcMchntInfo.getMchntName());
            /* 新增商户标志 */
            mcMchntInfoBean.setNewMchntFlag(mcMchntInfo.getNewMchntFlag());
            /* 退出标志 */
            mcMchntInfoBean.setExitFlag(mcMchntInfo.getExitFlag());
            /* 操作类型 */
            if ((mcMchntInfo.getNewMchntFlag().equals(CommonConstant.MCHNT_REFUSE_FLAG) || mcMchntInfo.getNewMchntFlag().equals(CommonConstant.MCHNT_NEW_FLAG)) && mcMchntInfo.getExitFlag().equals(CommonConstant.MC_EXIT_FLAG)) {
                mcMchntInfoBean.setOprType(CommonConstant.BIZ_OPR_INSERT);
            } else {
                mcMchntInfoBean.setOprType(CommonConstant.EMPTY_STRING);
            }
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("转换营销活动商户信息异常,异常信息:<{}>", byteArrayOutputStream.toString());
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return mcMchntInfoBean;
    }

    /**
     * 营销活动商户信息数据库临时表实体类和接口实体类数据转换
     *
     * @param tmPlatBizTmp 业务数据临时表
     * @return cc.rengu.igas.momp.facade.bean.McMchntInfoBean 营销活动商户信息对象
     * @author Jinan Liu
     * @date 2020/5/28 20:13
     */
    private McMchntInfoBean convertTmpMcMchntInfo(TMPlatBizTmp tmPlatBizTmp) {

        McMchntInfoBean mcMchntInfoBean = new McMchntInfoBean();
        try {

            JsonTmpMcMchntInfo jsonTmpMcMchntInfo = JsonOperation.parseTmpMcMchntInfoBizData1(tmPlatBizTmp, rglog);

            /* 商户范围类型 */
            mcMchntInfoBean.setMchntType(jsonTmpMcMchntInfo.getMchntType());
            /* 商户范围号 */
            mcMchntInfoBean.setMchntNo(jsonTmpMcMchntInfo.getMchntNo());
            /* 商户范围名称 */
            mcMchntInfoBean.setMchntName(jsonTmpMcMchntInfo.getMchntName());
            //是否是进行中新增商户
            if (tmPlatBizTmp.getAuditStatus().equals(AuditStatusEnum.NEW_AUDIT_PROCESSING.getAuditStatusCode()) || tmPlatBizTmp.getAuditStatus().equals(AuditStatusEnum.NEW_AUDIT_REJECT.getAuditStatusCode())
                    || tmPlatBizTmp.getAuditStatus().equals(AuditStatusEnum.PUBLISH_AUDIT_REJECT.getAuditStatusCode())) {
                /* 审批状态*/
                mcMchntInfoBean.setOprType(CommonConstant.BIZ_OPR_INSERT);
            } else {
                mcMchntInfoBean.setOprType(CommonConstant.EMPTY_STRING);
            }

        } catch (Exception e) {
            rglog.error("转换临时表营销活动机构信息异常,异常信息:<{}>", StringUtil.ExceptionToString(e));
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return mcMchntInfoBean;
    }

    /**
     * 营销活动用户规则信息数据库实体类和接口实体类数据转换
     *
     * @param mcUserInfo 营销活动用户信息表
     * @return cc.rengu.igas.momp.facade.bean.McUserInfoBean 营销活动用户信息对象
     * @author Jinan Liu
     * @date 2020/4/1 10:33
     */
    private McUserInfoBean convertMcUserInfo(TMMcUserInfo mcUserInfo) {
        McUserInfoBean mcUserInfoBean = new McUserInfoBean();
        try {
            /* 账户类型 */
            mcUserInfoBean.setAcctType(mcUserInfo.getAcctType());
            /* 账户 */
            mcUserInfoBean.setAcctNo(mcUserInfo.getAcctNo());
            /* 会员ID */
            mcUserInfoBean.setMemberId(mcUserInfo.getMemberId());
            /* 每日限制优惠次数 */
            mcUserInfoBean.setDayRestriction(mcUserInfo.getDayRestriction());
            /* 每周限制优惠次数 */
            mcUserInfoBean.setWeekRestriction(mcUserInfo.getWeekRestriction());
            /* 每月限制优惠次数 */
            mcUserInfoBean.setMonthRestriction(mcUserInfo.getMonthRestriction());
            /* 每季度限制优惠次数 */
            mcUserInfoBean.setQuerterRestriction(mcUserInfo.getQuerterRestriction());
            /* 每年限制优惠次数 */
            mcUserInfoBean.setYearRestriction(mcUserInfo.getYearRestriction());
            /* 活动期间优惠次数限制 */
            mcUserInfoBean.setRestriction(mcUserInfo.getRestriction());
            /** 账户标志 */
            mcUserInfoBean.setAcctFlag(mcUserInfo.getAcctFlag());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("转换营销活动商户信息异常,异常信息:<{}>", byteArrayOutputStream.toString());
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return mcUserInfoBean;
    }

    /**
     * 营销活动用户信息数据库临时表实体类和接口实体类数据转换
     *
     * @param tmPlatBizTmp 业务数据临时表
     * @return cc.rengu.igas.momp.facade.bean.McUserInfoBean 营销活动用户信息对象
     * @author Jinan Liu
     * @date 2020/5/28 20:16
     */
    private McUserInfoBean convertTmpMcUserInfo(TMPlatBizTmp tmPlatBizTmp) {
        McUserInfoBean mcUserInfoBean = new McUserInfoBean();
        try {

            JsonTmpMcUserInfo jsonTmpMcUserInfo = JsonOperation.parseTmpMcUserInfoBizData1(tmPlatBizTmp, rglog);

            /* 账户类型 */
            mcUserInfoBean.setAcctType(jsonTmpMcUserInfo.getAcctType());
            /* 账户 */
            mcUserInfoBean.setAcctNo(jsonTmpMcUserInfo.getAcctNo());
            /* 会员ID */
            mcUserInfoBean.setMemberId(jsonTmpMcUserInfo.getMemberId());
            /* 每日限制优惠次数 */
            mcUserInfoBean.setDayRestriction(jsonTmpMcUserInfo.getDayRestriction());
            /* 每周限制优惠次数 */
            mcUserInfoBean.setWeekRestriction(jsonTmpMcUserInfo.getWeekRestriction());
            /* 每月限制优惠次数 */
            mcUserInfoBean.setMonthRestriction(jsonTmpMcUserInfo.getMonthRestriction());
            /* 每季度限制优惠次数 */
            mcUserInfoBean.setQuerterRestriction(jsonTmpMcUserInfo.getQuerterRestriction());
            /* 每年限制优惠次数 */
            mcUserInfoBean.setYearRestriction(jsonTmpMcUserInfo.getYearRestriction());
            /* 活动期间优惠次数限制 */
            mcUserInfoBean.setRestriction(jsonTmpMcUserInfo.getRestriction());

        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("转换营销活动商户信息异常,异常信息:<{}>", byteArrayOutputStream.toString());
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return mcUserInfoBean;
    }

    /**
     * 营销活动时间规则信息数据库实体类和接口实体类数据转换
     *
     * @param mcTimeInfo 营销活动时间信息表
     * @return cc.rengu.igas.momp.facade.bean.McTimeInfoBean 营销活动事件对象
     * @author Jinan Liu
     * @date 2020/4/1 10:32
     */
    private McTimeInfoBean convertMcTimeInfo(TMMcTimeInfo mcTimeInfo) {
        McTimeInfoBean mcTimeInfoBean1 = new McTimeInfoBean();
        try {
            /* 顺序号 */
            mcTimeInfoBean1.setRuleIndex(mcTimeInfo.getRuleIndex());
            /* 星期一日期标志 */
            mcTimeInfoBean1.setFlagMonday(mcTimeInfo.getFlagMonday());
            /* 星期二日期标志 */
            mcTimeInfoBean1.setFlagTuesday(mcTimeInfo.getFlagTuesday());
            /* 星期三日期标志 */
            mcTimeInfoBean1.setFlagWednesday(mcTimeInfo.getFlagWednesday());
            /* 星期四日期标志 */
            mcTimeInfoBean1.setFlagThursday(mcTimeInfo.getFlagThursday());
            /* 星期五日期标志 */
            mcTimeInfoBean1.setFlagFriday(mcTimeInfo.getFlagFriday());
            /* 星期六日期标志 */
            mcTimeInfoBean1.setFlagSaturday(mcTimeInfo.getFlagSaturday());
            /* 星期日日期标志 */
            mcTimeInfoBean1.setFlagSunday(mcTimeInfo.getFlagSunday());
            /* 起始时间 */
            mcTimeInfoBean1.setStartTime(mcTimeInfo.getStartTime());
            /* 结束时间 */
            mcTimeInfoBean1.setEndTime(mcTimeInfo.getEndTime());

        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("转换营销活动商户信息异常,异常信息:<{}>", byteArrayOutputStream.toString());
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return mcTimeInfoBean1;
    }

    /**
     * 营销活动时间信息数据库临时表实体类和接口实体类数据转换
     *
     * @param tmPlatBizTmp 业务数据临时表
     * @return cc.rengu.igas.momp.facade.bean.McTimeInfoBean 营销活动时间对象
     * @author Jinan Liu
     * @date 2020/5/28 20:24
     */
    private McTimeInfoBean convertTmpMcTimeInfo(TMPlatBizTmp tmPlatBizTmp) {
        McTimeInfoBean mcTimeInfoBean = new McTimeInfoBean();
        try {

            JsonTmpMcTimeInfo jsonTmpMcTimeInfo = JsonOperation.parseTmpMcTimeInfoBizData1(tmPlatBizTmp, rglog);

            /* 顺序号 */
            mcTimeInfoBean.setRuleIndex(jsonTmpMcTimeInfo.getRuleIndex());
            /* 星期一日期标志 */
            mcTimeInfoBean.setFlagMonday(jsonTmpMcTimeInfo.getFlagMonday());
            /* 星期二日期标志 */
            mcTimeInfoBean.setFlagTuesday(jsonTmpMcTimeInfo.getFlagTuesday());
            /* 星期三日期标志 */
            mcTimeInfoBean.setFlagWednesday(jsonTmpMcTimeInfo.getFlagWednesday());
            /* 星期四日期标志 */
            mcTimeInfoBean.setFlagThursday(jsonTmpMcTimeInfo.getFlagThursday());
            /* 星期五日期标志 */
            mcTimeInfoBean.setFlagFriday(jsonTmpMcTimeInfo.getFlagFriday());
            /* 星期六日期标志 */
            mcTimeInfoBean.setFlagSaturday(jsonTmpMcTimeInfo.getFlagSaturday());
            /* 星期日日期标志 */
            mcTimeInfoBean.setFlagSunday(jsonTmpMcTimeInfo.getFlagSunday());
            /* 起始时间 */
            mcTimeInfoBean.setStartTime(jsonTmpMcTimeInfo.getStartTime());
            /* 结束时间 */
            mcTimeInfoBean.setEndTime(jsonTmpMcTimeInfo.getEndTime());

        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("转换营销活动商户信息异常,异常信息:<{}>", byteArrayOutputStream.toString());
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return mcTimeInfoBean;
    }

    /**
     * 营销活动规则信息数据库实体类和接口实体类数据转换
     *
     * @param mcCouponRuleInfo 卡券类营销活动规则表
     * @return cc.rengu.igas.momp.facade.bean.CouponRuleInfoBean 卡券类营销活动规则信息对象
     * @author Jinan Liu
     * @date 2020/4/1 10:32
     */
    private CouponRuleInfoBean convertMcRuleInfo(TMMcCouponRuleInfo mcCouponRuleInfo) {

        CouponRuleInfoBean couponRuleInfoBean = new CouponRuleInfoBean();

        try {

            /* 顺序号  */
            couponRuleInfoBean.setRuleIndex(mcCouponRuleInfo.getRuleIndex());
            /* 活动门槛 */
            couponRuleInfoBean.setCriteria(mcCouponRuleInfo.getCriteria());
            /* 卡券面额 */
            couponRuleInfoBean.setDenomination(mcCouponRuleInfo.getDenomination());
            /* 卡券数量 */
            couponRuleInfoBean.setQuantity(mcCouponRuleInfo.getQuantity());
            /* 单日核销数量 */
            couponRuleInfoBean.setDayRedeemLimit(mcCouponRuleInfo.getDayRedeemLimit());
            /* 购买标志 */
            couponRuleInfoBean.setPurchaseFlag(mcCouponRuleInfo.getPurchaseFlag());
            /* 购买金额 */
            couponRuleInfoBean.setPurchaseAmt(mcCouponRuleInfo.getPurchaseAmt());
            /* 批量任务状态 */
            couponRuleInfoBean.setBatchTaskStatus(mcCouponRuleInfo.getBatchTaskStatus());

        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("转换营销活动规则信息异常,异常信息:<{}>", byteArrayOutputStream.toString());
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return couponRuleInfoBean;
    }

    /**
     * 营销活动时间信息数据库临时表实体类和接口实体类数据转换
     *
     * @param tmPlatBizTmp 业务数据临时表
     * @return cc.rengu.igas.momp.facade.bean.CouponRuleInfoBean 卡券类营销活动规则信息对象
     * @author Jinan Liu
     * @date 2020/5/28 20:30
     */
    private CouponRuleInfoBean convertTmpMcRuleInfo(TMPlatBizTmp tmPlatBizTmp) {

        CouponRuleInfoBean couponRuleInfoBean = new CouponRuleInfoBean();

        try {

            JsonTmpCpMcRuleInfo jsonTmpCpMcRuleInfo = JsonOperation.parseTmpCpMcRuleInfoBizData1(tmPlatBizTmp, rglog);

            /* 顺序号  */
            couponRuleInfoBean.setRuleIndex(jsonTmpCpMcRuleInfo.getRuleIndex());
            /* 活动门槛 */
            couponRuleInfoBean.setCriteria(jsonTmpCpMcRuleInfo.getCriteria());
            /* 卡券面额 */
            couponRuleInfoBean.setDenomination(jsonTmpCpMcRuleInfo.getDenomination());
            /* 卡券数量 */
            couponRuleInfoBean.setQuantity(jsonTmpCpMcRuleInfo.getQuantity());
            /* 单日核销数量 */
            couponRuleInfoBean.setDayRedeemLimit(jsonTmpCpMcRuleInfo.getDayRedeemLimit());
            /* 购买标志 */
            couponRuleInfoBean.setPurchaseFlag(jsonTmpCpMcRuleInfo.getPurchaseFlag());
            /* 购买金额 */
            couponRuleInfoBean.setPurchaseAmt(jsonTmpCpMcRuleInfo.getPurchaseAmt());
            /* 批量任务状态 */
            couponRuleInfoBean.setBatchTaskStatus(jsonTmpCpMcRuleInfo.getBatchTaskStatus());

        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("转换营销活动规则信息异常,异常信息:<{}>", byteArrayOutputStream.toString());
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return couponRuleInfoBean;
    }

    /**
     * 营销活动支付产品信息数据库实体类和接口实体类数据转换
     *
     * @param mcProductInfo 营销活动产品信息表
     * @return cc.rengu.igas.momp.facade.bean.McProductInfoBean 营销活动产品对象
     * @author Jinan Liu
     * @date 2020/4/1 10:32
     */
    private McProductInfoBean convertMcProductInfo(TMMcProductInfo mcProductInfo) {
        McProductInfoBean mcProductInfoBean = new McProductInfoBean();
        try {
            /* 业务产品代码 */
            mcProductInfoBean.setBizProdCode(mcProductInfo.getBizProdCode());

        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("转换营销活动支付产品信息异常,异常信息:<{}>", byteArrayOutputStream.toString());
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return mcProductInfoBean;
    }

    /**
     * 营销活动产品信息数据库临时表实体类和接口实体类数据转换
     *
     * @param tmPlatBizTmp 业务数据临时表
     * @return cc.rengu.igas.momp.facade.bean.McProductInfoBean 营销活动产品对象
     * @author Jinan Liu
     * @date 2020/5/28 20:29
     */
    private McProductInfoBean convertTmpMcProductInfo(TMPlatBizTmp tmPlatBizTmp) {
        McProductInfoBean mcProductInfoBean = new McProductInfoBean();
        try {

            JsonTmpMcProdInfo jsonTmpMcProdInfo = JsonOperation.parseTmpMcProdInfoBizData1(tmPlatBizTmp, rglog);

            /* 业务产品代码 */
            mcProductInfoBean.setBizProdCode(jsonTmpMcProdInfo.getBizProdCode());

        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("转换营销活动支付产品信息异常,异常信息:<{}>", byteArrayOutputStream.toString());
            throw new BizException(RespCodeEnum.SYSTEM_ERROR.getRespCode(), RespCodeEnum.SYSTEM_ERROR.getRespDesc());
        }

        return mcProductInfoBean;
    }

    /**
     * 使用商户编号从内管商户基本信息表查询商户所属商圈编号
     *
     * @param globalInstId 法人机构号
     * @param mchntNo      商户编号
     * @return cc.rengu.igas.momp.common.entity.TBMchntBaseInfo 商户基本信息表T_B_MCHNT_BASE_INFO
     * @throws Exception 异常信息
     * @author Jinan Liu
     * @date 2020/5/28 13:06
     */
    private TBMchntBaseInfo selectMompMchntBaseInfoByPrimaryKey(String globalInstId, String mchntNo) throws Exception {

        MchntInfoMapper mchntInfoMapper = new MchntInfoMapperImpl();
        return mchntInfoMapper.selectMompMchntBaseInfoByPrimaryKey(globalInstId, mchntNo);
    }

}
